<?php
	header('Content-Type:application/json');  //此声明非常重要
	include('connect.php');
	$TIME = time();
	$TYPE = $_POST['TYPE'];
//	$TIME = '08:05%';
	if($TYPE=="user"){
		$sql = "SELECT * FROM list where times>$TIME-120 ";
		 $json['type'] = "user";  
	}else if($TYPE=="out"){
		$sql = "SELECT * FROM exportposition ";
		 $json['type'] = "out";  
	}else if($TYPE=='fir'){
		$sql = "SELECT * FROM totalinfo where nowState='疏散中' ";
		 $json['type'] = "fir";  
	}
	
   $result = mysqli_fetch_all(mysqli_query($db,$sql),MYSQLI_ASSOC);
    $json['num'] = count($result);    

    $json['info'] = $result;    
        //数据库查询结果保存为数组（注意第二个参数）
        // MYSQL_ASSOC - 关联数组
        // MYSQL_NUM - 数字数组
        // MYSQL_BOTH - 默认。同时产生关联和数字数组
        
//      $result=array();
//      $result["succeed"] = "1";
//      $size=1;
//      while ($arr = $trun->fetch_array(MYSQL_ASSOC)) {
//      	$result["userposition"][$size]["userID"]=$arr['userID'];
//			$result["userposition"][$size]["log"]=$arr['log'];
//			$result["userposition"][size]["lat"]=$arr['Lat'];
//			$size++;
//			}
//			if($arr!="array"){
//				$result["succeed"] = "2";
//			}else{
//				$result["succeed"] = "0";
//			}
//      foreach ($arr as $key => $value) {
//          //把键/值取出放到result数组的data下
//          $result["data"][$key] = $value;
//      }
        echo (json_encode($json)) ;
    
?>